﻿import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { environment } from '@env/environment';
// 母版页
import { LayoutDefaultComponent } from '../layout/default/default.component';
import { LayoutFullScreenComponent } from '../layout/fullscreen/fullscreen.component';
import { LayoutPassportComponent } from '../layout/passport/passport.component';
// 用户管理
import { UsersComponent } from './users/users.component';
// 栏目管理
import { ChannelComponent } from './channel/channel.component';
//ChannelGroup
import { ChannelGroupComponent } from './channelgroup/channelgroup.component';
//Role
import { RoleComponent } from './role/role.component';
//Department
import { DepartmentComponent } from './department/department.component';
//News
import { NewsComponent } from './news/news.component';
import { ListNewsComponent } from './news/list-news.component';
import { CreateNewsComponent } from './news/create-news.component';
import { EditNewsComponent } from './news/edit-news.component';
// Setting
import { SettingComponent } from './setting/setting.component';

//Category
import { CategoryComponent } from './category/category.component';
//Product
import { ProductComponent } from './product/product.component';
import { ListProductComponent } from './product/list-product.component';
import { CreateProductComponent } from './product/create-product.component';
import { EditProductComponent } from './product/edit-product.component';
//AlipaySetting
import { AlipaySettingComponent } from './alipaysetting/alipaysetting.component';
//WeixinSetting
import { WeixinSettingComponent } from './weixinsetting/weixinsetting.component';
// CodeGeneration_Bookmark_Import代码生成书签勿删除

// 登入和密码
import { UserLoginComponent } from './passport/login/login.component';
import { UserRegisterComponent } from './passport/register/register.component';
import { UserRegisterResultComponent } from './passport/register-result/register-result.component';
// 错误页面
import { CallbackComponent } from './callback/callback.component';
import { UserLockComponent } from './passport/lock/lock.component';
import { Exception403Component } from './exception/403.component';
import { Exception404Component } from './exception/404.component';
import { Exception500Component } from './exception/500.component'; 

const routes: Routes = [
  {
    path: '',
    component: LayoutDefaultComponent,
    children: [
      { path: '', redirectTo: 'users', pathMatch: 'full' },
      { path: 'setting', component: SettingComponent, data: { title: '站点配置' } },
      { path: 'users', component: UsersComponent, data: { title: '用户管理' } },
      { path: '', redirectTo: 'channel', pathMatch: 'full' },
      { path: 'channel', component: ChannelComponent, data: { title: '栏目管理' } },
      { path: 'channelgroup', component: ChannelGroupComponent, data: { title: '栏目组管理' } },
      { path: 'role', component: RoleComponent, data: { title: '用户角色' } },
      { path: 'department', component: DepartmentComponent, data: { title: '部门管理' } },
      {
        path: 'news', component: NewsComponent, data: { title: '内容管理' },
        children: [
          { path: '', redirectTo: 'list', pathMatch: 'full'},
          { path: 'list', component: ListNewsComponent, data: { title: '内容管理' }},
          { path: 'create', component: CreateNewsComponent, data: { title: '内容新增' } },
          { path: 'edit/:id', component: EditNewsComponent, data: { title: '内容修改' }}
        ]
      },
      { path: 'category', component: CategoryComponent, data: { title: '商品类型' } },
      { path: 'product', component: ProductComponent, data: { title: '商品管理' },
        children: [
            { path: '', redirectTo: 'list', pathMatch: 'full'},
            { path: 'list', component: ListProductComponent, data: { title: '商品管理' }},
            { path: 'create', component: CreateProductComponent, data: { title: '商品新增' } },
            { path: 'edit/:id', component: EditProductComponent, data: { title: '商品修改' }}
          ] 
      },
      { path: 'alipaysetting', component: AlipaySettingComponent, data: { title: '支付宝配置' } },
      { path: 'weixinsetting', component: WeixinSettingComponent, data: { title: '微信配置' } },
      // CodeGeneration_Bookmark_Routes代码生成书签勿删除无修改

      // 业务子模块
      // { path: 'widgets', loadChildren: './widgets/widgets.module#WidgetsModule' }
    ]
  },
  // 全屏布局
  // {
  //     path: 'fullscreen',
  //     component: LayoutFullScreenComponent,
  //     children: [
  //     ]
  // },
  // passport
  {
    path: 'passport',
    component: LayoutPassportComponent,
    children: [
      { path: 'login', component: UserLoginComponent, data: { title: '登录', titleI18n: 'pro-login' } },
      { path: 'register', component: UserRegisterComponent, data: { title: '注册', titleI18n: 'pro-register' } },
      { path: 'register-result', component: UserRegisterResultComponent, data: { title: '注册结果', titleI18n: 'pro-register-result' } }
    ]
  },
  // 单页不包裹Layout
  { path: 'callback/:type', component: CallbackComponent },
  { path: 'lock', component: UserLockComponent, data: { title: '锁屏', titleI18n: 'lock' } },
  { path: '403', component: Exception403Component },
  { path: '404', component: Exception404Component },
  { path: '500', component: Exception500Component },
  { path: '**', redirectTo: 'dashboard' }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: environment.useHash })],
  exports: [RouterModule]
})
export class RouteRoutingModule { }
